﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IGolovkine.ShoutCastRipper
{
    public class ContentLengthPolicy : IContentLengthPolicy
    {
        private readonly TimeSpan _min;
        private readonly TimeSpan _max;

        public ContentLengthPolicy(TimeSpan min, TimeSpan max)
        {
            if (min > max)
            {
                throw new ArgumentException(string.Format("Invalid {0} arguments: minimum content length cannot be greater than maximum content length", this.GetType().Name));
            }
            _min = min;
            _max = max;
        }

        public bool WithinMinimumLength(TimeSpan length)
        {
            return length > _min;
        }

        public bool WithinMaximumLength(TimeSpan length)
        {
            return length < _max;
        }
    }
}
